<?php

namespace App\Models;


class User extends BaseUser
{

    /**
     * The attributes that are mass assignable.
     *
     * @var list<string>
     */
    protected $fillable = ['name', 'email', 'password',];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var list<string>
     */
    //protected $hidden = ['password', 'remember_token',];


    // 用户管理
    protected $table = 'user';

    // 缓存字段，用于搜索绑定的字段
    protected $cacheFields = ['id'];

    // 登录的字段
    protected function loginField()
    {
        // 'last_ip', 'last_time',
        return ['id', 'username', 'password', 'salt', 'status', 'email', 'mobile',];
    }

    // 定义验证操作
    public function rules()
    {

        $add = [
            'username' => 'required',
            'salt'     => 'required',
        ];

        $edit = [
        ];

        $info = [
            'password' => ['max:129'],
            'is_del'   => ['in:0,1,2'],
            //'role'     => ['in:0,1,2'],
        ];

        $rule = [
            //'nickname' => 'required',
            //'role'       => ['required'],
            //'article_no' =>['numeric'],
            //'mobile'     =>['required'],
            'password' => ['max:65'],
            'role'     => ['in:0,1,2'],
            'status'   => ['in:0,1,2'],
        ];


        $msg = [
            'score'        => '积分',
            'username'     => '用户名（唯一且不变，用于阿特@操作）',
            'password'     => '密码',
            'nickname'     => '昵称（企业认证名称，因为程序中已经使用，所以不修改字段名）',
            'head_img'     => '头像',
            'mobile'       => '手机号',
            'phone'        => '电话',
            'email'        => '邮箱',
            'sex'          => '0-保密1-男 2-女',
            'openid'       => '微信openid',
            'is_recommend' => '推荐 1-是',
            'city'         => '所在城市',
            'reg_ip'       => '注册ip',
            'reg_time'     => '注册时间',
            'last_ip'      => '上次登录ip',
            'last_time'    => '上次登录时间',
            'sign'         => '个性签名',
            'is_auth'      => '是否认证手机号（1-是）',
            'verify'       => '是否审核（认证用户才需要审核）（1-是,审核通过，2-审核不通过）',
            'status'       => '状态 0-禁用 1-正常 -1-删除',
            'from_uid'     => '邀请人',
            'ctime'        => '创建时间',
            'mtime'        => '修改时间',
        ];

        return ['rule' => $rule, 'msg' => $msg, 'add' => $add, 'info' => $info];
    }
}
